package com.cx.dao;

import com.cx.pojo.Department;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/**
 * @auther: Centaury
 * @Date:2023/3/19 - 03 - 19 - 21:50
 */

// 模拟数据库数据
@Repository
public class DepartmentDao {

    private static Map<Integer, Department> departments = null;

    static{
        //创建一张部门表
        departments = new HashMap<>();
        departments.put(1001,new Department(1001,"市场部"));
        departments.put(1002,new Department(1002,"营销部"));
        departments.put(1003,new Department(1003,"运营部"));
        departments.put(1004,new Department(1004,"后勤部"));
        departments.put(1005,new Department(1005,"人力部"));
    }
    //查询所有部门
    public Collection<Department> getDepartments(){
        return departments.values();
    }

    // 通过id得到部门
    public Department getDepartmentById(Integer id){
        return departments.get(id);
    }

}
